home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 817 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. From: "Martin E. Nordberg III" <102571.1562@CompuServe.COM>
  2. Message-ID: <4isb5a$ct4$1@mhafc.production.compuserve.com>
  3. X-Original-Date: 21 Mar 1996 19:37:14 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 22 Mar 96 02:20:54 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: dynamic_cast<const B&>
  9. Organization: Quintessoft Engineering, Inc.
  10. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  11.     iQBFAgUBMVIOpOEDnX0m9pzZAQH4mAF/evelZ8rALzE0czYno0nvUJ6WQs8lpqEy
  12.     E5gmiR+Yg34TX9UAWqNVMyksUDdmFwwn
  13.     =V9c4
  14.  
  15.     I just installed MS VC++ 4.1.  The following code (strained 
  16. from my larger code) now fails to compile:
  17.  
  18.     class A { virtual ~A() };
  19.     class B : public A {};
  20.  
  21.     void test( const A&  a )
  22.       {
  23.         const B& b = dynamic_cast<const B&>( a );
  24.           // gives "... error ... cannot use dynamic_cast to 
  25.           // convert from 'const A &' to 'const B &' "
  26.       }
  27.  
  28.     Did Microsoft goof or did I?  The draft standard (Sect. 5.2.6) 
  29. seems to equate a reference to an lvalue for dynamic_cast, but 
  30. gives no clear wording for this case.  The same problem happens 
  31. for const A* to const B*.
  32.     If the new MSVC++ behavior is correct, why?
  33. (Eagerly awaiting BC++ 5.0, hope it really works with MFC)
  34.  
  35. -- 
  36. Martin E. Nordberg III
  37. Quintessoft Engineering, Inc.
  38. "Visualizing new patterns of software development."
  39. ---
  40. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  41. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  42. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  43. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  44. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  45.